﻿package mortal.game.view.shopMall.view
{
    import Message.Public.*;
    import com.gengine.utils.*;
    import com.mui.controls.*;
    import extend.language.*;
    import flash.utils.*;
    import mortal.common.*;
    import mortal.component.gconst.*;
    import mortal.game.cache.*;
    import mortal.game.events.*;
    import mortal.game.manager.*;
    import mortal.game.manager.msgTip.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.util.*;
    import mortal.game.view.shopMall.data.*;
    import mortal.mvc.core.*;

    public class ShopFeaturTips extends Object
    {
        public static var isShowing:Boolean = false;
        private static var _currentItem:ShopSellItem;
        private static var _currentShopItemData:ShopItemData;
        public static var closeCallback:Function;
        private static var useUnbindGoldModuleDic:Dictionary = new Dictionary();

        public function ShopFeaturTips()
        {
            return;
        }// end function

        public static function showUseUnbindWin(param1) : void
        {
            var enderAlert:Function;
            var closeHandler:Function;
            var item:* = param1;
            enderAlert = function () : void
            {
                _currentShopItemData.isUseGoldBuyGoldBind = true;
                if (_currentItem && _currentItem.shopItemData)
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.BuyItem, item));
                }
                else if (_currentShopItemData)
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.BuyItem, _currentShopItemData));
                }
                return;
            }// end function
            ;
            closeHandler = function (param1:int, param2:Boolean = false) : void
            {
                isShowing = false;
                if (closeCallback != null)
                {
                    closeCallback.apply();
                    closeCallback = null;
                }
                if (param1 == Alert.OK)
                {
                    return;
                }
                if (_currentShopItemData)
                {
                    _currentShopItemData.isUseGoldBuyGoldBind = false;
                }
                return;
            }// end function
            ;
            if (item is ShopSellItem)
            {
                _currentItem = item;
                _currentShopItemData = (item as ShopSellItem).shopItemData;
            }
            else if (item is ShopItemData)
            {
                _currentShopItemData = item;
            }
            isShowing = true;
            var unit:* = _currentShopItemData.unit;
            var money:* = _currentShopItemData.totalPrize - Cache.instance.role.getMoneyByType(_currentShopItemData.unit);
            var str:* = Language.getStringByParam(35567, GameDefConfig.instance.getEPrictUnitName(unit), money, GameDefConfig.instance.getEPrictUnitName(MoneyUtil.getBindUnit(unit)));
            TodayNotTipUtil.toDayNotTip(TodayNoTipsConst.ShopUseGoldWin, enderAlert, str, null, Alert.OK | Alert.CANCEL, null, closeHandler);
            return;
        }// end function

        public static function setIsUseGoldByType(param1:String, param2:Boolean) : void
        {
            useUnbindGoldModuleDic[param1] = param2;
            return;
        }// end function

        public static function isUseGoldByType(param1:String) : Boolean
        {
            return useUnbindGoldModuleDic[param1];
        }// end function

        public static function showUseGlodWin(param1:String, param2:int, param3:String, param4:Function = null, param5:Function = null, ... args) : void
        {
            args = new activation;
            var moduleType:* = param1;
            var cost:* = param2;
            var desc:* = param3;
            var cancelCallBack:* = param4;
            var continuteCallBack:* = param5;
            var arg:* = args;
            if (Cache.instance.role.enoughMoney(EPriceUnit._EPriceUnitGoldBind, ))
            {
                if (!Cache.instance.role.enoughMoney(EPriceUnit._EPriceUnitGoldBind, , null, false))
                {
                    if (!useUnbindGoldModuleDic[])
                    {
                        var closeHandler:* = function (param1:int, param2:Boolean = false) : void
            {
                if (param1 == Alert.OK)
                {
                    useUnbindGoldModuleDic[moduleType] = true;
                    if (continuteCallBack != null)
                    {
                        continuteCallBack.apply(null, arg);
                    }
                }
                else
                {
                    useUnbindGoldModuleDic[moduleType] = false;
                    if (cancelCallBack != null)
                    {
                        cancelCallBack.apply();
                    }
                }
                return;
            }// end function
            ;
                        cost =  - Cache.instance.role.getMoneyByType(EPriceUnit._EPriceUnitGoldBind);
                        desc = StringHelper.substitute(, );
                        Alert.isFlowMouse = true;
                        Alert.show(, null, Alert.OK | Alert.CANCEL, null, , null, 4);
                    }
                    else if ( != null)
                    {
                        apply(null, );
                    }
                }
                else if ( != null)
                {
                    apply(null, );
                }
            }
            else
            {
                MsgManager.showRollTipsMsg(Language.getString(35199), MsgRollTipsType.msgRollTips3);
                if ( != null)
                {
                    apply();
                }
            }
            return;
        }// end function

    }
}
